event | NN 4 IE 4 DOM n/a | ||||
While the event
object contains information about a user- or system-generated event
in Navigator and Internet Explorer, the event mechanisms for the two
browser families are very different, as described in | |||||
Object Model Reference
|
altKey | NN n/a IE 4 DOM n/a | ||
Read-only | |||
Reveals the state of the | |||
Exampleif (event.altKey) { } | |||
Value Boolean value: true | false. | |||
|
cancelBubble | NN n/a IE 4 DOM n/a | ||
Read/Write | |||
Specifies whether the event should propagate (bubble) up the element container hierarchy. You usually only need to set this property to true to override the default behavior and prevent the event from going any further. | |||
Examplewindow.event.cancelBubble = true | |||
Value Boolean: true | false. | |||
|
clientX, clientY | NN n/a IE 4 DOM n/a | ||
Read-only | |||
The horizontal (x) and vertical (y) coordinate of the mouse at the moment the current event fired. These coordinates are relative to the viewable document area of the browser window or frame. | |||
Exampleif ((event.clientX >= 10 || event.clientX <= 20) && (event.clientY >= 50 || event.clientY <= 100)) { } | |||
Value Integer of pixel values. | |||
|
ctrlKey | NN n/a IE 4 DOM n/a | ||
Read-only | |||
Whether the | |||
Exampleif (event.ctrlKey) { } | |||
Value Boolean value: true | false. | |||
|
data | NN 4 IE n/a DOM n/a | ||
Read-only | |||
Accessory data associated with the event. As of Navigator 4, the only event for which the data property has information is the dragdrop event, in which case the data property returns the URL of the item being dropped onto the window or frame. | |||
Examplevar srcDoc = evtObj.data | |||
Value String. | |||
|
fromElement | NN n/a IE 4 DOM n/a | ||
Read-only | |||
Returns a reference to the object where the cursor had been just prior to the onMouseOver or onMouseOut event. | |||
Exampleif (event.fromElement.id == "lowerLevel") { ... } | |||
Value Object reference. | |||
|
keyCode | NN n/a IE 4 DOM n/a | ||
Read/Write | |||
The Unicode key value for the keyboard key that triggered the event.
For onKeyPress events, the value represents the
actual character displayed in a text box (e.g., 65 for
"A" and 97 for "a"). But for
onKeyDown and onKeyUp events,
only the uppercase value is returned, regardless of the case of the
character that is rendered. If the event is not keyboard driven, the
value is zero. While you may change the value of this property, it
does not influence the character displayed in the text field. See
| |||
Exampleif (event.keyCode == 65) { ... } | |||
Value Integer. | |||
|
layerX, layerY | NN 4 IE n/a DOM n/a | ||
Read-only | |||
The horizontal (x) and vertical (y) coordinate of the mouse at the moment the current event fired. These coordinates are relative to the containing layer. If no layers or positionable elements have been defined, the default layer of the base document is used as a reference point, thus being equivalent to the pageX and pageY properties. | |||
Exampleif ((evtObj.layerX >= 10 || evtObj.layerX <= 20) && (evtObj.layerY >= 50 || evtObj.layerY <= 100)) { } | |||
Value Integer of pixel values. | |||
|
modifiers | NN 4 IE n/a DOM n/a | ||
Read-only | |||
An integer that represents the keyboard modifier key(s) being held
down at the time the event fired. You can use the
& operator with a series of
Event object constants to find out whether a
particular modifier key was pressed. See | |||
Examplevar altKeyPressed = evtObj.modifiers & Event.ALT_MASK | |||
Value Integer. | |||
|
offsetX, offsetY | NN n/a IE 4 DOM n/a | ||
Read-only | |||
The left and top coordinates of the mouse pointer relative to the containing element (exclusive of padding, borders, or margins) when the event fired. You can determine the containing element via the offsetParent property. See the section "About client- and offset- Properties" at the beginning of this chapter about offset measurement anomalies in Internet Explorer 4. | |||
Exampleif (event.offsetX <= 20 && event.offsetY <=40) { ... } | |||
Value Integer pixel count. | |||
|
pageX, pageY | NN 4 IE n/a DOM n/a | ||
Read-only | |||
The left and top coordinates of the element's content relative to the top-left corner of the page area when the event fired. The measurements ignore any scrolling of the page. | |||
Exampleif (evtObj.pageX <= 20 && evtObj.pageY <=40) { ... } | |||
Value Integer pixel count. | |||
|
reason | NN n/a IE 4 DOM n/a | ||||||
Read-only | |||||||
Returns a code associated with an onDataSetComplete event signifying whether the data transfer was successful or, if incomplete, whether the transfer stopped due to an error or a stoppage by the client or user. This property must be examined in an event handler for the onDataSetComplete event. | |||||||
Exampleif (event.reason == 2) { alert("An error occurred during the most recent update.") } | |||||||
Value One of three possible integer values:
| |||||||
|
returnValue | NN n/a IE 4 DOM n/a | ||
Read/Write | |||
The value to be returned to the event's source element to allow or prohibit the element's default action connected with the event. If you set event.returnValue to false, the element does not carry out its normal operation, such as navigating to a link or submitting the form. | |||
Exampleevent.returnValue = "false" | |||
Value Boolean value: true | false. | |||
|
screenX, screenY | NN 4 IE 4 DOM n/a | ||
Read-only | |||
Horizontal and vertical pixel coordinate points where the cursor was located on the video screen when the event occurred. The top-left corner of the screen is point 0,0. There is no particular coordination with the browser window, unless you have positioned the window and know where the active window area is in relation to the screen. | |||
Example// NN if (evtObj.screenX < 5 || evtObj.screenY < 5) { alert("You\'re too close to the edge!") } // IE if (event.screenX < 5 || event.screenY < 5) { alert("You\'re too close to the edge!") } | |||
Value Any positive integer or zero. | |||
|
shiftKey | NN n/a IE 4 DOM n/a | ||
Read-only | |||
Reveals the state of the | |||
Exampleif (event.shiftKey) { } | |||
Value Boolean value: true | false. | |||
|
srcElement | NN n/a IE 4 DOM n/a | ||
Read-only | |||
Reference to the element object that fired the current event. This property is convenient in switch constructions for an event handler function that handles the same event type for a number of different elements. | |||
Exampleswitch (event.srcElement.id) { case myDIV: ... ... } | |||
Value Object reference. | |||
|
srcFilter | NN n/a IE 4 DOM n/a | ||
Read-only | |||
Reference to the filter object that fired the current onFilterChange event. This property is convenient in switch constructions for an event handler function that handles the same event type for a number of different elements. | |||
Exampleswitch (event.srcFilter.id) { case myDIV: ... ... } | |||
Value Object reference. | |||
|
target | NN 4 IE n/a DOM n/a | ||
Read-only | |||
Reference to the element object that is the intended destination of the current event. This property is convenient in switch constructions for an event handler function that handles the same event type for a number of different elements. | |||
Exampleswitch (evtObj.target.name) { case "myButton": ... ... } | |||
Value Object reference. | |||
|
toElement | NN n/a IE 4 DOM n/a | ||
Read-only | |||
Returns a reference to the object to which the cursor has moved that triggered the onMouseOut event. | |||
Exampleif (event.toElement.id == "upperLevel") { ... } | |||
Value Object reference. | |||
|
type | NN 4 IE 4 DOM n/a | ||
Read-only | |||
The type of the current event (without the "on" prefix). Values are all lowercase. | |||
Example// NN if (evtObj.type == "change") { ... } // IE if (event.type == "change") { ... } | |||
Value Any event name (without the "on" prefix) as a string. | |||
|
which | NN 4 IE n/a DOM n/a | ||
Read-only | |||
Returns a value relevant to the type of event. For mouse events, the property value is an integer indicating which mouse button was used (1 is the left button; 3 is the right button). For keyboard events, the property value is an integer of the keyboard character ASCII code. | |||
Exampleif (evtObj.which == 65) { ... } | |||
Value Integer. | |||
|
x, y | NN n/a IE 4 DOM n/a | ||
Read-only | |||
Returns the horizontal and vertical pixel coordinates of the mouse pointer at the time the event occurred. The coordinate system is either a positioned element or the BODY element. A value of -1 is returned if the pointer was outside of the document area of the browser window. | |||
Exampleif (event.x < 20 && event.y < 30) { ... } | |||
Value Integer. | |||
|